Imports System.IO

Module WriteBinaryData

    Sub Main()
        Dim Stream As FileStream=Nothing
        Try
            Stream = New FileStream("C:\File.dat", FileMode.Create)
        Catch E As Exception
            Console.WriteLine("Loi tao file  File.Dat")
            Console.WriteLine("Error {0}", E.Message)
        End Try
        Dim BinaryStream As New BinaryWriter(Stream)
  
      Dim Age As Integer = 21
        Dim Salary As Double = 100000.0
        Dim Name As String = "Nha sach Minh Khai"

        Try
            BinaryStream.Write(Age)
            BinaryStream.Write(Salary)
            BinaryStream.Write(Name)
            BinaryStream.Close()

            Console.WriteLine("Du lieu da ghi xong")
        Catch E As Exception
            Console.WriteLine("Loi ghi du lieu")
            Console.WriteLine("Error {0}", E.Message)
        End Try

        Console.ReadLine() 

    End Sub
End Module
